#include <iostream>
using namespace std;
	int counter_mas1=0;
	int counter_mas2=0;
	int counter1_mas1=0;
	int counter2_mas2=0;
	
int minimum(int *a,int *b)
{
	
	if(*a<*b)
	{
		counter_mas1++;
		return *a;
	}
	if(*a>*b)
	{
		counter_mas2++;
		return *b;
	}

}
void funk(int *pmas1,int *pmas2,int *pmas3,const int n,const int m)
{	int i=0;

	while(counter2_mas2<m)
		{
		
			pmas3[i]=minimum(pmas1,pmas2);
			i++;
			if(counter_mas1==1)
			{
				pmas1++;
				counter1_mas1++;
				counter_mas1=0;
			}
			else if(counter_mas2==1)
			{
			pmas2++;
			counter2_mas2++;
			counter_mas2=0;
			}
		}
	while(counter1_mas1<n)
		{
			pmas3[i]=*pmas1;
			pmas1++;i++;
			counter1_mas1++;
		}
	
}
void main()
{
	const int n=10;
	const int m=8;
	int mas1 [n]={1,3,5,7,9,11,13,15,17,18};
	int mas2 [m]={2,4,6,8,10,12,14,16};
	int mas3[n+m];
	int *pmas1;
	pmas1=mas1;
	int *pmas2;
	pmas2=mas2;
	int *pmas3;
	pmas3=mas3;
	funk(pmas1,pmas2,pmas3,n,m);
	
	for(int i=0;i<n+m;i++)
	{
		cout<<mas3[i]<<" ";
	}
	cout<<endl;


}